package applications.away3d {
	import display3d.away3d.TestSkeleton3D;
	import away3d.cameras.Camera3D;
	import away3d.containers.Scene3D;
	import away3d.lights.DirectionalLight3D;
	import core.SkeletonTest;
	import display3d.away3d.Doll3D;
	import display3d.away3d.ViewContainer3D;
	import flash.events.Event;
	import flash.geom.Vector3D;
	import jazztures.objects.Skeleton;
	import jazztures.plugins.away3d.Skeleton3D;




	
	
	[SWF(width=1000, height=800, frameRate=30, backgroundColor=0xFFFFFF)]
	public class KinectSkeletonAway3D extends SkeletonTest
	{
		
		private var camera:Camera3D;
		private var view:ViewContainer3D;
		protected var world:Scene3D;
		private var light:DirectionalLight3D;
	
		
		public function KinectSkeletonAway3D()
		{
			super();
		}
		
		override protected function build():void{
			world = new Scene3D();
			
			light = new DirectionalLight3D();
			light.direction = new Vector3D(150,150,150);
			world.addLight(light);
		
			camera = new Camera3D();
			camera.x = stage.stageWidth/4;
			camera.y = -stage.stageHeight/4;
			camera.zoom = 9;
			camera.focus = 400;
			world.addChild(camera);
			
			view = new ViewContainer3D(stage.stageWidth, stage.stageHeight, camera, world);
			addChild(view);
			
			addEventListener(Event.ENTER_FRAME, render);
		}
		
		private function render(evt:Event):void{
			view.render();
		}
		
		override protected function updateSkeleton(skeleton:Skeleton, skeleton3D:Object):void{
			skeleton3D.skeleton = skeleton;
			skeleton3D.update();
		}
		
		override protected function createSkeleton():Object{
			var skeleton3D:Skeleton3D = new TestSkeleton3D();
			world.addChild(skeleton3D);
			return skeleton3D;
		}
		
		override protected function destroySkeleton(skeleton:Object):void{
			world.removeChild(skeleton as Skeleton3D);
		}
		
	}
}